package threading;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-03-18
 * Time: 19:11
 */
public class ThreadDemo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread [] threads=new Thread[20];
        for(int i=0;i<20;i++){
            final   int n=i;

           threads[i]=new Thread(new Runnable() {
               @Override
               public void run() {
                   System.out.println(n);
               }
           });
        }
        for (Thread t:threads) {
            t.start();
        }
        for (Thread t:threads) {
            t.join();
        }
        System.out.println("ok");
    }
}
